import clientEnum from "./client.enum"
import Sensor from "./Sensor"

export default class CreateSensorRoutine {
  key: string
  argsDef: { argNames: string[]; varArg: boolean }
  observableRegistry: any
  collectionRegistry: any
  sensorCalls: { addSource: any; dispose: any; showDebug: any }
  constructor(t) {
    this.key = "sensor.create"
    this.argsDef = { argNames: ["type"], varArg: !1 }
    this.observableRegistry = t.observableRegister
    this.collectionRegistry = t.collectionRegister
    this.sensorCalls = {
      addSource: t.functionRegister.register("Sensor.addSource", clientEnum.it),
      dispose: t.functionRegister.register("sensor.dispose", clientEnum.rt),
      showDebug: t.functionRegister.register("sensor.showDebug", clientEnum.nt)
    }
  }
  buildMessageData(t, e) {
    return e
  }
  async onResponse(t, e) {
    const s = this.observableRegistry.register(e.sensorId),
      i = this.collectionRegistry.register(e.sensorId)
    return new Sensor(e.sensorId, this.sensorCalls, s, i).facade
  }
}
